//
//  ViewController.m
//  TestAll
//
//  Created by zhaoguoying on 2017/9/27.
//  Copyright © 2017年 ZDHS. All rights reserved.
//

#import "ViewController.h"
#import "RC.h"
#import "ChatListVC.h"
#import "AppDelegate.h"
#import "Masonry.h"


@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
//    NSArray *arr = @[@"登录用户1",@"登录用户2"];
//    for (int i=0; i<arr.count; i++) {
//        UIButton *btn = [UIButton buttonWithType:(UIButtonTypeSystem)];
//        btn.frame = CGRectMake(self.view.width/2-80, 100+i*80, 160, 40);
//        [btn setTitle:arr[i] forState:(UIControlStateNormal)];
//        [btn addTarget:self action:@selector(btnAction:) forControlEvents:(UIControlEventTouchUpInside)];
//        [self.view addSubview:btn];
//        btn.tag = 101+i;
//    }
    
    
}
#pragma mark - _init
#pragma mark - delegate
#pragma mark - action
#pragma mark - other

-(void)btnAction:(UIButton *)btn{
    NSString *token;
    if (btn.tag==101) {
        token = @"tMsWGAB4haJio1aSY3SGOsFvgNRKc5o2@ky35.cn.rongnav.com;ky35.cn.rongcfg.com";
    } else {
        token = @"gigORq3tdcpio1aSY3SGOuiTtg3lusPp@ky35.cn.rongnav.com;ky35.cn.rongcfg.com";
    }
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    
    
    
    
    
    [[RCIM sharedRCIM] connectWithToken:token dbOpened:^(RCDBErrorCode code) {
        NSLog(@"");
    }success:^(NSString *userId) {
        NSLog(@"登录成功");
        kshowMsg(@"登录成功");
        
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [CurAppDelegate mainRootVC];
            [MBProgressHUD hideHUDForView:self.view animated:YES];
        });
        
    }error:^(RCConnectErrorCode status) {
        NSLog(@"登录失败");
        kshowMsg(@"登录失败");
        dispatch_async(dispatch_get_main_queue(), ^{
            [MBProgressHUD hideHUDForView:self.view animated:YES];
        });
    }];
}


@end
